home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
COMMADIO
/
PYROMNT.LZH
/
PRESERVE.LZH
/
PRESERVE.BAT
< prev
next >
Wrap
DOS Batch File
|
1989-07-16
|
3KB
|
114 lines
@ECHO OFF
IF X%1X == XX GOTO SHOWHELP
GOTO CKFNC
:SHOWHELP
ECHO ·
ECHO Format for this command: PRESERVE archive-file-name [file-spec]
ECHO ·
ECHO Examples: PRESERVE INVOICES Archives all files to A:
ECHO PRESERVE DATABASE *.DAT Archives DAT files to A:
ECHO ·
ECHO You must be in the directory which you want to back up to diskette.
ECHO The archive must not exceed the capacity of one floppy.
ECHO ·
GOTO DONE
REM ---------- Check for filename collision ----------
:CKFNC
IF EXIST %1.ZIP GOTO ALREADY
GOTO NOZIP
:ALREADY
CLS
ECHO %1.ZIP already exists in this directory -- choose a different name.
GOTO DONE
REM ---------- Review command ----------
:NOZIP
ECHO ·
ECHO ╔══════════╗
ECHO ║ PRESERVE ║
ECHO ╚══════════╝
IF X%2X == XX GOTO ALLOFIT
ECHO ·
ECHO Preserving %2 on %1 archive on drive A:
GOTO PUTDISK
REM ---------- Review directory ----------
:ALLOFIT
DIR /W
QUERY Do you want to preserve this directory on diskette? (Y/N) @ YN
IF ERRORLEVEL 3 GOTO DONE
REM ---------- Format diskette if needed ----------
:PUTDISK
CLS
ECHO Insert the diskette in the A: drive.
QUERY Should the diskette be formatted? (Y/N) @YN
IF ERRORLEVEL 2 GOTO SHOWA
FORMAT A:
REM Modify the following line to feed the answers into FORMAT
REM FORMAT A: <C:\MISCUTIL\FMT.INP
GOTO TESTCU
REM ---------- Show A: ----------
:SHOWA
CLS
ECHO Directory of the A: drive ...
DIR A:
QUERY Continue? (Y/N) @ YN
IF ERRORLEVEL 3 GOTO DONE
REM ---------- Test need for clean-up ----------
:TESTCU
IF X%2X == XX GOTO DELNE
GOTO MAKEZIP
REM ---------- Delete non-essential files ----------
:DELNE
QUERY Delete BAK, BK! and TPU files? @ YN
IF ERRORLEVEL 3 GOTO DELZIP
@ECHO ON
DEL *.BAK
DEL *.BK!
DEL *.TPU
@ECHO OFF
REM ---------- Delete archives ----------
:DELZIP
IF EXIST *.ZIP GOTO DODELZIP
GOTO MAKEZIP
:DODELZIP
DIR *.ZIP /W
QUERY Delete archive(s)? @YN
IF ERRORLEVEL 2 GOTO MAKEZIP
QUERY Are you SURE you want to delete ZIP and PAK files? @YN
IF ERRORLEVEL 2 GOTO MAKEZIP
@ECHO ON
DEL *.ZIP
DEL *.PAK
@ECHO OFF
REM ---------- Create archive ----------
:MAKEZIP
IF X%2X == XX GOTO NOSPEC
PKZIP -aex %1 %2
IF ERRORLEVEL 0 GOTO DOCOPY
GOTO ZIPFAIL
:NOSPEC
PKZIP -aex %1 *.*
IF ERRORLEVEL 0 GOTO DOCOPY
:ZIPFAIL
REM Many archiving programs don't set ErrorLevel
ECHO ═══ ARCHIVE FAILED! ═══
ECHO Nothing was preserved
ECHO ═══════════════════════
DEL %1.ZIP
GOTO DONE
REM ---------- Copy archive to diskette ----------
:DOCOPY
ECHO ·
COPY %1.ZIP A:
IF ERRORLEVEL 0 GOTO CLEANUP
ECHO ═══ COPY FAILED! ═══
ECHO ZIP file not deleted
ECHO ════════════════════
GOTO DONE
REM ---------- Clean up ----------
:CLEANUP
DEL %1.ZIP
ECHO ·
ECHO PRESERVE successful
DIR A:
:DONE